/*
 * cpu.h
 *
 * Copyright (C) 2016 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _CPU_H_
#define _CPU_H_

#include <common.h>
#include <sdk/cpu.h>

#define CPU_FEATURE_FPU   (1 << 0)
#define CPU_FEATURE_VME   (1 << 1)
#define CPU_FEATURE_DE    (1 << 2)
#define CPU_FEATURE_PSE   (1 << 3)
#define CPU_FEATURE_TSC   (1 << 4)
#define CPU_FEATURE_MSR   (1 << 5)
#define CPU_FEATURE_PAE   (1 << 6)
#define CPU_FEATURE_MCE   (1 << 7)
#define CPU_FEATURE_CX8   (1 << 8)
#define CPU_FEATURE_APIC  (1 << 9)
#define CPU_FEATURE_SEP   (1 << 11)
#define CPU_FEATURE_MTRR  (1 << 12)
#define CPU_FEATURE_PGE   (1 << 13)
#define CPU_FEATURE_MCA   (1 << 14)
#define CPU_FEATURE_CMOV  (1 << 15)
#define CPU_FEATURE_PAT   (1 << 16)
#define CPU_FEATURE_PSE36 (1 << 17)
#define CPU_FEATURE_PSN   (1 << 18)
#define CPU_FEATURE_CLFL  (1 << 19)
#define CPU_FEATURE_DTES  (1 << 21)
#define CPU_FEATURE_ACPI  (1 << 22)
#define CPU_FEATURE_MMX   (1 << 23)
#define CPU_FEATURE_FXSR  (1 << 24)
#define CPU_FEATURE_SSE   (1 << 25)
#define CPU_FEATURE_SSE2  (1 << 26)
#define CPU_FEATURE_SS    (1 << 27)
#define CPU_FEATURE_HTT   (1 << 28)
#define CPU_FEATURE_TM1   (1 << 29)
#define CPU_FEATURE_IA64  (1 << 30)
#define CPU_FEATURE_PBE   (1 << 31)

extern void cpu_init(void);
extern void cpu_measure_speed(void);
extern void fpu_save(byte_t *data);
extern void fpu_restore(byte_t *data);
extern void stall(dword_t microseconds);

extern char cpu_vendor[13];
extern dword_t cpu_features[2];

#endif
